#include <iostream>

using namespace std;

struct Node
{
	int data;
	Node* next;

	Node()
	{
		data = 0;
		next = nullptr;
	}

	Node(int x, Node* p = nullptr)
	{
		data = x;
		next = p;
	}
};

Node* head = nullptr;

void push(Node*& head, int x)
{
	Node* tmp = new Node(x, head);
	head = tmp;
}

int pop(Node*& head)
{
	if (head == nullptr)
		return ~(1 << 1);
	Node* tmp = head;
	int data = tmp->data;
	head = tmp->next;
	delete tmp;
	return data;
}

bool empty(Node* head)
{
	return head == nullptr;
}

int query(Node* head)
{
	if (head)
		return head->data;
	else return ~(1 << 31);
}
